package com.totcy.atom.presenter;

import android.content.Context;

import com.totcy.atom.bean.BannerBean;
import com.totcy.atom.model.BannerModel;
import com.totcy.atom.presenter.contract.BannerContract;
import com.totcy.baselibrary.base.mvpbase.BasePresenterImpl;

import java.util.List;

/**
 * description : 主页新闻presenter
 *
 * @author : Totcy
 * @date : 2017/12/8 17:49
 * @update : 2017/12/8
 */

public class BannerPresenter extends BasePresenterImpl<BannerContract.View, BannerContract.Model> implements BannerContract.Presenter {

    public BannerPresenter(Context context) {
        super(context);
    }

    @Override
    public BannerContract.Model attachModel() {
        return new BannerModel(mContext);
    }

    @Override
    public void getBannerList() {
        if (isModelAttached()) {
            getModel().getBannerList(new BannerContract.Model.DataCallback() {
                @Override
                public void onBannerList(List<BannerBean> beans) {
                    if (isViewAttached()) {
                        getView().onBannerData(beans);
                    }
                }
            });
        }
    }
}
